package com.nf.health.app.activity.intervene.adatper;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nf.health.app.R;
import com.nf.health.app.activity.intervene.NoDataInterveneFragment;
import com.nf.health.app.customview.CircleImageView;
import com.nf.health.app.utils.ViewUtil;

/**
 * Created by Administrator on 2017/1/19/019.
 */

public class Inter_ItemAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater inflater;

    public Inter_ItemAdapter(Context context){
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return 12;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHodler viewHodler = null;
        if(convertView==null){
            viewHodler = new ViewHodler();
            convertView = inflater.inflate(R.layout.inter_item,null);
            viewHodler.tv_per_item = ViewUtil.getView(convertView,R.id.tv_per_item);
            viewHodler.civ_per_item = ViewUtil.getView(convertView,R.id.civ_per_item);
            convertView.setTag(viewHodler);
        }else{
            viewHodler = (ViewHodler) convertView.getTag();
        }
        switch (position){
            case 0:
                setMyData(viewHodler,"高血压",R.drawable.iv_blood_info);
               break;
            case 1:
                setMyData(viewHodler,"糖尿病",R.drawable.iv_sugar_info);
               break;
            case 2:
                setMyData(viewHodler,"血脂异常",R.drawable.iv_blood_zhi_info);
                break;
            case 3:
                setMyData(viewHodler,"颈肩腰腿疼痛",R.drawable.iv_nack_info);
                break;
            case 4:
                setMyData(viewHodler,"慢阻肺/慢支炎/肺心病",R.drawable.iv_lung_info);
                break;
            case 5:
                setMyData(viewHodler,"中风偏瘫/面瘫",R.drawable.iv_face_info);
                break;
            case 6:
                setMyData(viewHodler,"月经不调",R.drawable.iv_formal_info);
                break;
            case 7:
                setMyData(viewHodler,"肥胖",R.drawable.iv_fatter_info);
                break;
            case 8:
                setMyData(viewHodler,"失眠",R.drawable.iv_nosleep_info);
                break;
            case 9:
                setMyData(viewHodler,"亚健康",R.drawable.iv_second_health_info);
                break;
            case 10:
                setMyData(viewHodler,"出院病人",R.drawable.iv_out_doc_persion_info);
                break;
            case 11:
                setMyData(viewHodler,"尽情期待",R.drawable.iv_jqqd_info);
                break;
        }
        return convertView;
    }
    private class ViewHodler{
        private TextView tv_per_item;
        private CircleImageView civ_per_item;
    }
    private void setMyData(ViewHodler viewHodler,String testConmsg,int imgResId){
        viewHodler.tv_per_item.setText(testConmsg);
        viewHodler.civ_per_item.setImageResource(imgResId != 0 ? imgResId : R.drawable.default_image);
    }

}
